#include<bits/stdc++.h>
using namespace std;
struct node{
    int wz,lj;
};
int main() {
        freopen("detect.in","r",stdin);
        freopen("detect.out","w",stdout);
        int T;
        cin>>T;
        while(T--) {
            int n,m,L,V;
            cin>>n>>m>>L>>V;
            int d[n],v[n],a[n];
            for(int i=0;i<n;i++) cin>>d[i]>>v[i]>>a[i];
            node mp[m];
            for(int i=0;i<m;i++) cin>>mp[i].wz;
            bool f[n];
            int ans=0;
            memset(f,0,sizeof(f));
            for(int i=0;i<m;i++) {
                for(int j=0;j<n;j++) {
                    if(f[j]) continue;
                    if(mp[i].wz<d[j]) continue;
                    if(sqrt(v[j]*v[j]+2*a[j]*(mp[i].wz-d[j]))>V) {
                        f[j]=1;
                        ans++;
                        mp[i].lj++;
                    }
                }
            }
            cout<<ans<<" ";
            //cout<<ans<<"\n";
            int ans2=0;
            for(int i=0;i<m;i++) {
                if(mp[i].lj<ans-1) ans2++;
            }
            cout<<ans2<<"\n";
        }
        return 0;
}
